// const isLandscape = ref(false);
export default function useOrientation() {
  /*const alpha = ref<number | null>(null);
  const beta = ref<number | null>(null);
  const gamma = ref<number | null>(null);
  const rotationAngle = ref(0);
  const initialAlpha = ref<number | null>(null);
  const permissionGranted = ref(false);
  const isSupported = ref("DeviceOrientationEvent" in window);

  // 检查方向条件
  const checkLandscapeCondition = () => {
    if (alpha.value === null || initialAlpha.value === null) return false;
    // 计算旋转角度（-180°~180°）
    let angle = (alpha.value - initialAlpha.value + 360) % 360;
    if (angle > 180) angle -= 360;
    rotationAngle.value = angle;

    // 是否逆时针旋转 ≥45°
    const isRotatedCCW = angle >= 45;

    // 是否在第二/第三象限（左倾 + 明显前后倾斜）
    const isInSecondOrThirdQuadrant =
      gamma.value !== null &&
      beta.value !== null &&
      gamma.value < 0 &&
      Math.abs(beta.value) > 30;

    // 是否在第六/第七象限（左倾 + 接近平放）
    const isInSixthOrSeventhQuadrant =
      gamma.value !== null &&
      beta.value !== null &&
      gamma.value < 0 &&
      Math.abs(beta.value) < 30;

    return (
      (isInSecondOrThirdQuadrant && isRotatedCCW) ||
      (isRotatedCCW && isInSixthOrSeventhQuadrant)
    );
  };

  // 处理方向变化
  const handleOrientation = (event: DeviceOrientationEvent) => {
    alpha.value = event.alpha;
    beta.value = event.beta;
    gamma.value = event.gamma;

    if (initialAlpha.value === null && alpha.value !== null) {
      initialAlpha.value = alpha.value;
    }

    isLandscape.value = checkLandscapeCondition();
  };

  // 请求权限（iOS）
  const requestPermission = async () => {
    if (
      typeof DeviceOrientationEvent !== "undefined" &&
      typeof (DeviceOrientationEvent as any).requestPermission === "function"
    ) {
      try {
        const response = await (
          DeviceOrientationEvent as any
        ).requestPermission();
        permissionGranted.value = response === "granted";
        return permissionGranted.value;
      } catch (error) {
        console.error("Device orientation permission denied:", error);
        return false;
      }
    }
    return true; // 非iOS设备默认有权限
  };

  // 初始化
  const init = async () => {
    if (!isSupported.value) {
      console.warn("Device orientation not supported");
      return;
    }

    const hasPermission = await requestPermission();
    if (!hasPermission) return;

    // 添加事件监听
    window.addEventListener("deviceorientation", handleOrientation);

    // 立即检查初始状态
    if (alpha.value !== null && initialAlpha.value !== null) {
      isLandscape.value = checkLandscapeCondition();
    }
  };

  // 清理
  const cleanup = () => {
    window.removeEventListener("deviceorientation", handleOrientation);
  };

  // 生命周期
  onMounted(init);
  onUnmounted(cleanup);

  return {
    isLandscape,
    alpha,
    beta,
    gamma,
    rotationAngle,
    initialAlpha,
    permissionGranted,
    isSupported,
    requestPermission
  };
*/
  return {
    isLandscape: ref(true)
  };
}
